/*
 * @Title: community
 * @Description: TODO
 * @author MI
 * @date 2022/7/25 10:58
 * @version
 */
package com.shanshan.community.util;

import com.shanshan.community.entity.User;
import org.springframework.stereotype.Component;

/**
 * @author MI
 * @ClassName: HostHolder
 * @Description: 持有用户数据，代替session
 * @date 2022/7/25 10:58
 */


@Component
public class HostHolder {
    private final ThreadLocal<User> users = new ThreadLocal<>();

    public void setUser(User user) {
        users.set(user);
    }

    public User getUser() {
        return users.get();
    }


    public void clear() {
        users.remove();
    }
}
